#include "../searchEngine/io.h"
#include "../searchEngine/hasher.h"
#include <cstdio>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
using namespace std;
using namespace Stream;
using namespace Hashing;


char buf[30000];

string word;

map<ll,string> hashes;

ll value(char *s)
{
	ll v=0;
	while (*s)
		v*=10 , v+=*s-'0', ++s;
	return v;
}



int main(int argc,char **argv)
{
	FastIstream stream(fopen("morfologik.txt","r"));
	int line = 0;
	ll hash;
	if (argc < 2)
		hash = 1111111111117ULL;
	else
	    hash = value(argv[1]);
	while (stream.getLine(buf))
	{
		istringstream s(buf);
		while (s >> word)
		{
			ll v = hasher::value(word.c_str(),hash);
			if (hashes.find(v)!=hashes.end() && word != hashes[v])
			{
				cout << v << ' ' << line << ' ' << word << "  = " << hashes[v] << '\n';
				return 0;
			}
			hashes[v]=word;
		}
		++line;
		if (line%1000==0)
			printf("linia %d\n",line);
	}
	printf("brak kolizji");


	return 0;

}